﻿using FastEndpoints.Security;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace vite_core.Common
{
    public static class JwtHelpler
    {
        public static string CreateToken(string signingKey, List<string> roleIds, string userName, string userId)
        {
            var jwtToken = JwtBearer.CreateToken(
                o =>
                {
                    o.SigningKey = signingKey;
                    o.ExpireAt = DateTime.UtcNow.AddDays(1);
                    o.User.Roles.AddRange(roleIds);
                    o.User.Claims.Add((SysConstant.LogClaimUserName, userName));
                    o.User[SysConstant.LogClaimUserId] = userId;
                });
            return jwtToken;
        }
    }
}
